package com.fh.Thread_Use;
/*
请编写一个程序，创建两个线程，一个线程每隔1秒输出“hello，world”，输出10次，退出.
一个线程每隔1秒输出“hi”，输出5次退出.
 */
public class Thread03 {
    public static void main(String[] args) throws InterruptedException {
        A a = new A();
        a.start();
        B b = new B();
        new Thread(b).start();

    }
}
class A extends Thread {
    int count = 0 ;
    @Override
    public void run() {
        while(true) {
            System.out.println("hello world"+(++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(count == 10) {
                break;
            }
        }
    }
}
class B implements Runnable {
    int count = 0 ;
    @Override
    public void run() {
        while(true) {
            System.out.println("hi"+(++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(count == 5) {
                break;
            }
        }
    }
}